package rentalstore;

import java.util.Enumeration;
import java.util.Vector;

public class Customer {

    private String name;
    private Vector rentals = new Vector();

    public Customer(String name) {
        this.name = name;
    }

    public void addRental(Rental arg){
        rentals.addElement(arg);
    }

    public String getName() {
        return name;
    }

    public double getTotalAmount() {
        Enumeration rentals = this.rentals.elements();
        double totalMount = 0;
        while (rentals.hasMoreElements()) {
            totalMount += ((Rental) rentals.nextElement()).computeAmount();
        }
        return totalMount;
    }

    public int getTotalFrequentRenterPoints() {
        Enumeration rentals = this.rentals.elements();
        int totalFrequentRenterPoints = 0;
        while (rentals.hasMoreElements()) {
            totalFrequentRenterPoints += ((Rental) rentals.nextElement()).computeFrequentRenterPoints();
        }
        return totalFrequentRenterPoints;
    }

    public String statement(){
        return new DefaultStatement().generate(getName(), this.rentals, getTotalAmount(), getTotalFrequentRenterPoints());
    }

    public String htmlStatement() {
        return new HtmlStatement().generate(getName(), this.rentals, getTotalAmount(), getTotalFrequentRenterPoints());
    }

}
